home *** CD-ROM | disk | FTP | other *** search
- Path: news.nyu.edu!schonberg!dewar
- From: dewar@cs.nyu.edu (Robert Dewar)
- Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++,comp.edu
- Subject: Re: ANSI C and POSIX (was Re: C/C++ knocks the crap out of Ada)
- Date: 9 Apr 1996 20:46:55 -0400
- Organization: Courant Institute of Mathematical Sciences
- Message-ID: <dewar.829096975@schonberg>
- References: <JSA.96Feb16135027@organon.com> <dewar.828936837@schonberg> <4kb2j8$an0@solutions.solon.com> <dewar.829011320@schonberg> <4kcsnsINNgkb@keats.ugrad.cs.ubc.ca> <dewar.829051685@schonberg> <829066525snz@genesis.demon.co.uk>
- NNTP-Posting-Host: schonberg.cs.nyu.edu
- X-Newsreader: NN version 6.5.0 (NOV)
-
- Lawrence says
-
- "Correctness considerations aside, there is never a good reason to pass
- a value in the 3rd argument to read() that is greater than the available
- buffer size. IMHO code that does this is highly suspect whether or not
- you argue that it is legal. I wish more systems were like Linux and trapped
- this, maybe they will in the future."
-
- Highly imprecise thinking here I fear. There is no practical way for
- any implementation to do the check you mention (this = value in 3rd
- argument that is greater than the available buffer size). This is
- C remember! We are passing a pointer, the caller routine has no way
- of knowing the buffer length, and in general unless you keep structured
- pointers which now the bounds of the object they reference (something
- no real C compiler does), there is no way to make the check.
-
- Linux simply checks that the end of the buffer is in the memory area,
- which is not the check you would like to see. That's what I was talking
- about when I noted that this kind of uncertainty would not occur in
- a language with a reasonably complete type model.
-
- What exactly *is* the wording of the POSIX standard here (Lawrence, you
- must have it at hand, please quote it exactly). The interesting thing
- is to determine whether this definition says enough to make *any* use
- of read defined without appealing to "unwritten rules". I would guess
- not!
-
-